package demo1;

import java.util.concurrent.TimeUnit;

public class Main1 {
    public static void main(String[] args) {
        MyQueue queue=new MyQueue(100);
        Thread t1 =new Thread(()->{
            int num=0;
            while (true){
                try {
                    queue.put(num);
                    System.out.println("生产: "+num);
                    num++;
                    TimeUnit.MILLISECONDS.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t1.start();
        Thread t2 =new Thread(()->{
            while (true){
                try {
                    System.out.println("消费任务"+queue.take());
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t2.start();
    }
}
